import { Dao, DatabaseDao, SQL, SQLiteDatabase } from '../../Index';
import { SqlReturnTypes } from '../../src/main/ets/common/Types';

import UserTable from './UserTable';

const QueryEmailList = SQL
  .select(UserTable.email)
  .form(UserTable)
  .where()
  .isNoNull(UserTable.email)

export type UserEmail = SqlReturnTypes<typeof QueryEmailList>

export class UserDao extends Dao {
  private readonly userDao = DatabaseDao.form(this).select(UserTable)
  private readonly db = SQLiteDatabase.form(this)

  async getEmailList(): Promise<UserEmail[]> {
    return this.db.querySql(QueryEmailList)
  }
}